package cn.ljlao.mall.product.goods.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;

@Service
public class TestService {

    @Autowired
    JdbcTemplate jdbcTemplate;

    @DS("test")
    //@Transactional(propagation = Propagation.REQUIRES_NEW)
    void v1(){
        String dsKey = DynamicDataSourceContextHolder.peek();
        System.out.println(dsKey);
        jdbcTemplate.execute("INSERT INTO `student`(`id`, `name`, `tid`) VALUES (7, '小王', 1)");
    }
}
